using System.Runtime.InteropServices.WindowsRuntime;

public abstract class ActionTransition : FSMTransition
{
    protected  ActionState fromAction => this.fromState as ActionState;
    protected  ActionState toAction => this.toState as ActionState;

    protected RoleEntity role => toAction.role;
    
    public ActionTransition( FSMState toState) : base( toState)
    {

    }
    protected ActionTransition(ActionState @from, ActionState to) : base(@from, to)
    {
        
    }
}

/// <summary>
/// 过程型动作过渡
/// </summary>
public class ProgressActionTransition:ActionTransition
{
    public ProgressActionTransition(ProgressAction from, ActionState to) : base(from, to)
    {
        
    }

    public override bool Meet()
    {
        ProgressAction from = this.fromAction as ProgressAction;

        return from.finished;
    }
}

public class Any2DieTransition : ActionTransition
{
    public Any2DieTransition( ActionState to) : base( to)
    {
        
    }

    public override bool Meet()
    {
        return this.role.dead;
    }
}

public class Die2IdleTransition : ActionTransition
{
    public Die2IdleTransition(ActionState @from, ActionState to) : base(@from, to)
    {
        
    }

    public override bool Meet()
    {
        return !this.role.dead;
    }
}

/// <summary>
/// any -> byHit
/// </summary>
public class Any2ByHitTransition : ActionTransition
{
    public Any2ByHitTransition(ActionState to) : base(to)
    {
        
    }

    public override bool MeetSign(int sign)
    {
        return !this.role.dead &&  sign == ActionStateType.byHit;
    }
}

/// <summary>
/// any -> attack
/// </summary>
public class Any2AttackTransition : ActionTransition
{
    public Any2AttackTransition( ActionState to) : base(to)
    {
        
    }

    public override bool MeetSign(int sign)
    {
        return sign == ActionStateType.attack;
    }
}


/// </summary>
/// sign transition
/// </summary>
public class SignTransition : ActionTransition
{
    private int m_Sign;
    public SignTransition(int sign, ActionState to) : base(to)
    {
        m_Sign = sign;
    }

    public override bool MeetSign(int sign)
    {
        return sign == m_Sign;
    }
}
